//
//  UIButton + Extension.swift
//  WeiBo_One
//
//  Created by apple on 15/10/19.
//  Copyright © 2015年 蜡笔小炎. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(imageName: String, backImageName: String) {
        self.init()
        
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: (imageName + "_highlighted")), forState: .Highlighted)
        
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: (backImageName + "_highlighted")), forState: .Highlighted)
        sizeToFit()
    }
    
    
    convenience init(title: String, color: UIColor, fontSize: CGFloat, backImageName: String) {
        self.init()
        
        setTitle(title, forState: .Normal)
        setTitleColor(color, forState: .Normal)
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        sizeToFit()
    }
}
